home *** CD-ROM | disk | FTP | other *** search
/ PC World 2008 February (DVD) / PCWorld_2008-02_DVD.iso / v cisle / PHP / PHP.exe / xampp-win32-1.6.5-installer.exe / php / PEAR / CodeGen / Element.php < prev    next >
Encoding:
PHP Script  |  2007-12-20  |  4.9 KB  |  245 lines

  1. <?php
  2. /**
  3.  * Abstract base class for all code elements
  4.  *
  5.  * PHP versions 5
  6.  *
  7.  * LICENSE: This source file is subject to version 3.0 of the PHP license
  8.  * that is available through the world-wide-web at the following URI:
  9.  * http://www.php.net/license/3_0.txt.  If you did not receive a copy of
  10.  * the PHP License and are unable to obtain it through the web, please
  11.  * send a note to license@php.net so we can mail you a copy immediately.
  12.  *
  13.  * @category   Tools and Utilities
  14.  * @package    CodeGen
  15.  * @author     Hartmut Holzgraefe <hartmut@php.net>
  16.  * @copyright  2005 Hartmut Holzgraefe
  17.  * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
  18.  * @version    CVS: $Id: Element.php,v 1.5 2006/02/17 09:47:00 hholzgra Exp $
  19.  * @link       http://pear.php.net/package/CodeGen
  20.  */
  21.  
  22. /**
  23.  * Abstract base class for all code elements
  24.  *
  25.  * @category   Tools and Utilities
  26.  * @package    CodeGen
  27.  * @author     Hartmut Holzgraefe <hartmut@php.net>
  28.  * @copyright  2005 Hartmut Holzgraefe
  29.  * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
  30.  * @version    Release: @package_version@
  31.  * @link       http://pear.php.net/package/CodeGen
  32.  */
  33. abstract class CodeGen_Element 
  34. {
  35.     /**
  36.      * The function name
  37.      *
  38.      * @var     string
  39.      */
  40.     protected $name  = "unknown";
  41.  
  42.     /**
  43.      * Name setter
  44.      *
  45.      * @param  string  function name
  46.      * @return bool    success status
  47.      */
  48.     function setName($name) 
  49.     {
  50.         $this->name = $name;
  51.             
  52.         return true;
  53.     }
  54.  
  55.  
  56.     /**
  57.      * Name getter
  58.      *
  59.      * @return  string  function name
  60.      */
  61.     function getName() 
  62.     {
  63.         return $this->name;
  64.     }
  65.  
  66.  
  67.     /**
  68.      * A short description
  69.      *
  70.      * @var     string
  71.      */
  72.     protected $summary = "";
  73.  
  74.     /**
  75.      * Summary setter
  76.      *
  77.      * @param  string  function summary
  78.      * @return bool    success status
  79.      */
  80.     function setSummary($text)
  81.     {
  82.         $this->summary = $text;
  83.         return true;
  84.     }
  85.  
  86.  
  87.  
  88.  
  89.     /**
  90.      * A long description
  91.      *
  92.      * @var     string
  93.      */
  94.     protected $description  = "";
  95.  
  96.     /**
  97.      * Description setter
  98.      *
  99.      * @param  string  function description
  100.      * @return bool    success status
  101.      */
  102.     function setDescription($text)
  103.     {
  104.         $this->description = $text;
  105.         return true;
  106.     }
  107.  
  108.  
  109.  
  110.     /**
  111.      * Conditional compile condition
  112.      *
  113.      * @var string
  114.      */
  115.     protected $ifCondition = "";
  116.     
  117.     /**
  118.      * ifCondition setter
  119.      *
  120.      * @param string preprocessor #if condition
  121.      */
  122.     function setIfCondition($code)
  123.     {
  124.       $this->ifCondition = $code;
  125.     }
  126.  
  127.  
  128.     /**
  129.      * Checks whether a string is a reserved name
  130.      *
  131.      * @access public
  132.      * @param  string name
  133.      * @return bool   true if reserved
  134.      */
  135.     function isKeyword($name) 
  136.     {
  137.         return false;
  138.     }
  139.  
  140.  
  141.  
  142.     /**
  143.      * Checks whether a string is a valid C name
  144.      *
  145.      * @access public
  146.      * @param  string The name to check
  147.      * @return bool   true for valid names, false otherwise
  148.      */
  149.     function isName($name) 
  150.     {
  151.         if (preg_match('|^[a-z_]\w*$|i',$name)) {
  152.             // TODO reserved words
  153.             return true;
  154.         } 
  155.         return false;
  156.     }
  157.  
  158.     /**
  159.      * Generate C code for element
  160.      *
  161.      * @access  public
  162.      * @param   string Extension name
  163.      * @return  string C code 
  164.      */
  165.     function cCode($name)
  166.     {
  167.         return ""; 
  168.     }
  169.  
  170.     /**
  171.      * Generate C code header block for all elements of this class
  172.      *
  173.      * @access public
  174.      * @param  string Extension name
  175.      * @return string C code
  176.      */
  177.     static function cCodeHeader($name) 
  178.     {
  179.         return "";
  180.     }
  181.  
  182.     /**
  183.      * Generate C code footer block for all elements of this class
  184.      *
  185.      * @access public
  186.      * @param  string Extension name
  187.      * @return string C code
  188.      */
  189.     static function cCodeFooter($name) 
  190.     {
  191.         return "";
  192.     }
  193.  
  194.     /**
  195.      * Generate C include file definitions for element
  196.      *
  197.      * @access  public
  198.      * @param  class Extension  extension we are owned by
  199.      * @return  string C header code 
  200.      */
  201.     function hCode($extension) 
  202.     {
  203.         return "";
  204.     }
  205.  
  206.     /**
  207.      * Generate documentation code for element
  208.      *
  209.      * @access  public
  210.      * @param   string id basename for extension
  211.      * @return  string documentation content
  212.      */
  213.     function docEntry($extension)
  214.     {
  215.         return "";
  216.     }
  217.  
  218.     /**
  219.      * Generate documentation header block for all elements of this class
  220.      *
  221.      * @access public
  222.      * @param  string Extension name
  223.      * @return string documentation fragment
  224.      */
  225.     static function docHeader($name) 
  226.     {
  227.         return "";
  228.     }
  229.  
  230.     /**
  231.      * Generate documentation footer block for all elements of this class
  232.      *
  233.      * @access public
  234.      * @param  string Extension name
  235.      * @return string documentation fragment
  236.      */
  237.     static function docFooter($name) 
  238.     {
  239.         return "";
  240.     }
  241.  
  242. }
  243.  
  244. ?>
  245.